	function editGame(i_RowNum, i_GameID){
		$("#row"+i_RowNum+"EditBtn").attr('hidden',true);
		$("#row"+i_RowNum+"DeleteBtn").attr('hidden',true);
		$("#row"+i_RowNum+"SaveBtn").attr('hidden',false);
		$("#row"+i_RowNum+"CancelBtn").attr('hidden',false);
		var divDate = $("#row"+i_RowNum+"Date > div");
		var divBuyIn = $("#row"+i_RowNum+"BuyIn > div");
		var divRebuy = $("#row"+i_RowNum+"Rebuy > div");
		var divRemark = $("#row"+i_RowNum+"Remark > div");
		var currDate = divDate.html();
		var currBuyIn = divBuyIn.html();
		var currRebuy = divRebuy.html();
		var currRemark = divRemark.html();
		divDate.attr('hidden',true);
		divBuyIn.attr('hidden',true);
		divRebuy.attr('hidden',true);
		divRemark.attr('hidden',true);
		$("#row"+i_RowNum+"Date").append("<input type='date' value='"+currDate+"'>");
		$("#row"+i_RowNum+"BuyIn").append("<input type='number' value='"+currBuyIn+"'>");
		$("#row"+i_RowNum+"Rebuy").append("<input type='number' value='"+currRebuy+"'>");
		$("#row"+i_RowNum+"Remark").append("<input type='text' value='"+currRemark+"'>");
	}
	
	function cancelEditGame(i_RowNum, i_GameID){
		$("#row"+i_RowNum+"EditBtn").attr('hidden',false);
		$("#row"+i_RowNum+"DeleteBtn").attr('hidden',false);
		$("#row"+i_RowNum+"SaveBtn").attr('hidden',true);
		$("#row"+i_RowNum+"CancelBtn").attr('hidden',true);
		$("#row"+i_RowNum+"Date > input").remove();
		$("#row"+i_RowNum+"BuyIn > input").remove();
		$("#row"+i_RowNum+"Rebuy > input").remove();
		$("#row"+i_RowNum+"Remark > input").remove();
		$("#row"+i_RowNum+"Date > div").attr('hidden',false);
		$("#row"+i_RowNum+"BuyIn > div").attr('hidden',false);
		$("#row"+i_RowNum+"Rebuy > div").attr('hidden',false);
		$("#row"+i_RowNum+"Remark > div").attr('hidden',false);
	}
	
	function saveEditGame(i_RowNum, i_GameID){
		var newDate = $("#row"+i_RowNum+"Date > input").val();
		var newBuyIn = $("#row"+i_RowNum+"BuyIn > input").val();
		var newRebuy =  $("#row"+i_RowNum+"Rebuy > input").val();
		var newRemark =  $("#row"+i_RowNum+"Remark > input").val();
		
		if (newDate && newBuyIn && newRebuy){
			$("#row"+i_RowNum+"EditBtn").attr('hidden',false);
			$("#row"+i_RowNum+"DeleteBtn").attr('hidden',false);
			$("#row"+i_RowNum+"SaveBtn").attr('hidden',true);
			$("#row"+i_RowNum+"CancelBtn").attr('hidden',true);
		
			$.ajax({
				url : "servletGame",
				type : "POST",
				data : {
					action : "update",
					gameID : i_GameID,
					gameDate : newDate,
					gameBuyIn : newBuyIn,
					gameRebuy : newRebuy,
					gameRemark : escapeStr(newRemark)
				},
				success : function(data, status){
					if (data.report == "success")
						{
						$("#row"+i_RowNum+"Date > div").html(newDate);
						$("#row"+i_RowNum+"BuyIn > div").html(newBuyIn);
						$("#row"+i_RowNum+"Rebuy > div").html(newRebuy);
						$("#row"+i_RowNum+"Remark > div").html(newRemark);
						$("#row"+i_RowNum+"TotalPot").html(data.totalPot);
						$("#row"+i_RowNum+"TotalWinnings").html(data.totalWinnings);
						$("#row"+i_RowNum+"NumPlayers").html(data.numPlayers);
						$("#row"+i_RowNum+"Tip").html(data.tip);
						}
					else {
						alert ("Couldn't update row!");
					}
					$("#row"+i_RowNum+"Date > input").remove();
					$("#row"+i_RowNum+"BuyIn > input").remove();
					$("#row"+i_RowNum+"Rebuy > input").remove();
					$("#row"+i_RowNum+"Remark > input").remove();
					$("#row"+i_RowNum+"Date > div").attr('hidden',false);
					$("#row"+i_RowNum+"BuyIn > div").attr('hidden',false);
					$("#row"+i_RowNum+"Rebuy > div").attr('hidden',false);
					$("#row"+i_RowNum+"Remark > div").attr('hidden',false);
				}
			});
		}
	}
	
	function deleteGame(i_RowNum,i_GameID){
		if (confirm("About to delete a row!"))
		  {
			$.ajax({
				url : "servletGame",
				type : "POST",
				data : {
					action : "delete",
					gameID : i_GameID
				},
				success : function(data, status){
					if (data.report == "success")
						{
						$("#row"+i_RowNum).fadeOut();					
						}
					else {
						alert ("Couldn't delete row!");
					}
				}
			});
		  }
}